DEV Community

How do you commit in GitHub ?

Nazim Boudeffa on September 09, 2018

I don't know if it's me or my dudeist attitude but when I start a project on GitHub, the first thing I do is to create a project on my profile on t...
Collapse
 
codeandclay profile image
Oliver • Edited

My personal preference is to git add ... -p. Eyeballing each line as I commit it gives me one last sanity check.

I also like to git commit -v so I can refer to the code whilst writing the commit message.

One thing I do a lot is that I like to create a new branch for even the smallest of changes. If I find I need to further prepare for that change, I can create a new branch from master, make the change then head back to the original new branch and rebase.

I also git reset --hard a lot. And, git commit --fixup ... helps me keep my commits tidy but I know if I'm using it a lot, I'm on my way to a mess.

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

You look like an advanced user @updated_tos , do you have a tutorial reference please ?

Collapse
 
codeandclay profile image
Oliver • Edited

These are things I've picked up as I've gone along. I got burnt by git too often when I started out.

Thread Thread
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

tbh I first follow the official documentation in any technology I use and in this case my steps are taken from the official hello world and I didn't change it from the beggining just learned to git add . and always work on the master branch which is not the best as i see in our discussion here

And I just noticed that it is said :

  • Create a repo on the site first O.o

After that it's all about how to commit so it's why I titled this post "How do you commit in GitHub" to start a discussion and to go ahead easy

Collapse
 
revskill10 profile image
Truong Hoang Dung • Edited
  • Create a useless branch
  • Accidentally make it useful
  • Really commit to merge the branch to remote master
  • Keep calm and merge the pull request to master
  • Revert the branch
  • Remove the repo
  • Repeat.
Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

What I notice is :

  • Create a branch

I understand that you don't work directly on a master branch

  • Remove the repo

I understand that you don't use that functionality of pulling a remote repo

Can you explain those two points a little bit more please @revskill10

Collapse
 
revskill10 profile image
Truong Hoang Dung

It's just a funny way to hack on your ideas until it works, then you remove the repo and re-create it with your refined idea ;)

Thread Thread
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Intresting gonna think about it, thank you for the reply

Collapse
 
aurelkurtula profile image
aurel kurtula

I start working on a project, when I need to add the first commit I

  • git init
  • Head over to Gitlab (where I host most my personal work),
  • Create a repo copy the remote setting and drop in in terminal
  • gitit "some commit message"
  • If I want to experiment I create branches

That's it.

I've set gitit to do this:

gitit() {
    git add .
    git commit -a -m "$1"
    git push --all
}

Quick and easy

(I do the same with Github)

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

As you said Quick and easy, I like it, I mostly like this feature of creating a branch, I've seen the idea three times in this thread.

Anyway, did you moved to gitlab after M$ bought GiThub ? ;) ;) We should post a subject like this to discuss it here should bring a lot of discussions

Collapse
 
aurelkurtula profile image
aurel kurtula

I create branches because I feel it is a clearer pinpoint to states I might want to visit later on.

No, I started using gitlab because of the unlimited private repos. So every time I'm creating a new project I "throw" it in gitlab worry free whether or not it's worth of public use. I used to use bitbucket but gitlab's interface is nicer

And since starting dabbling in web dev I had to change computers two times. The first was a horrible experience, me thinking I backed up everything when I didn't. The second time, having had everything (dev related) in GitLab, the transition was so smooth.

Now I have started using GitHub as a public portfolio (though it's still empty apart from code I've created for tutorials I wrote)

Thread Thread
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

I had this logic in the beggining to use other sites then GitHub for private repos then I decided to just use GitHub and when I have to treat a spciale topic or a specifical technology I just create another account (not in the sens of fake) and work on it to let people have a complete idea of what am doing, for instance I'll be creating a repo just for react in the furure

Collapse
 
jeikabu profile image
jeikabu

Just wanted to wish you good luck on the game jam.

I never really use commit -m. It's personal preference, I guess, but I'm usually either using a GUI front-end for git or feel more comfortable being able to compose it with vim.

Initially start pushing directly to master, but at some point (when the project is out of the "proof of concept" phase) I'll push to a branch. It's a good habit to get into. But, honestly, with a "throw away" project (like a game jam) I would probably just stick with master.

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Thank you for the reply @jeikabu , interesting point to use a special tool to commit. btw, I've seen an excellent post on moving from vim to neovim but am an atom editor addict now and I am testing how to commit with the GitHub app and clone directly a repo from the original project with it till I find my way of doing things until "a proof of concept" phase where I'll probably follow your idea

dev.to is in a "proof of concept" phase isn't it

Waiting for the githubgameoff2018 wish to see you there ;)

Collapse
 
jeikabu profile image
jeikabu

Don't just use the GUI for commits, I find it useful for general repository browsing, wrangling branches, etc. Still have to do some things from the command line (like sub-tree and LFS shenanigans), but I like the pretty colors when keeping an eye on a bunch of developers, tons of branches, etc.

Truth be told, I rarely use vim these days (except for commit messages in a git terminal). I'm a VS Code convert. ;)

Thread Thread
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Too much complicated for me because I think I don't have the right tools to follow the work on specifical repo

We can create some posts about it here to discuss also the topic about VSCode and Atom should be a good post too by releving what was said on the AMA of the new GitHub CEO on Reddit

Collapse
 
ahmedmusallam profile image
Ahmed Musallam

gitkraken. 'nuff said.

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Nice proposition, I was just saying I don't have to right tools to follow the work that is done on my prefered repos, can't follow the commits and the issues other place then using the GH GUI and discussing on GitHub, will the tool you propose save me from beeing lost ?

Collapse
 
ahmedmusallam profile image
Ahmed Musallam

I don't think I'm following your question. I think GitKraken is the best GUI for GIT that I've ever used.. and I used most of them. Since I started using GitKraken, I have not had to use the command-line at all. It's very intuitive and straightforward.

Thread Thread
 
cjbrooks12 profile image
Casey Brooks

I complely agree, GitKraken is a game-changer for git GUIs. I tend to do most of my git remote/branching work in the terminal, but the commit graph and it's commit previews just look so darn good. it's all I use for creating commits and exploring history

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

I like the enthusiasm that comes with this software, sorry for misunderstanding I am a french speaker in fact and sometimes I start explaining things in english and don't have the right words for it

It cost nothing to give a try so am on my way to test it thx for the discovery

Collapse
 
georgecoldham profile image
George

New project:

  • Create repo on GitHub
  • git clone <link to my repo>

If working on my own stuff, im lazy and just work in master:

  • Use VS Code git diff view to double check code
  • Add files in VS Code or in terminal using git add . depending on what im doing
  • Write and submit commit message in VS Code or git commit -m "my message"
  • Always in terminal git push

If im working on an actual project i create a branch before that step:

  • git checkout -b "feature/my-branch-name"
  • Steps as above
  • git push

Although on personal projects im actually lazier than I really let on I have aliased it all so:

  • gcm "commit message"
  • gp
Collapse
 
niorad profile image
Antonio Radovcic

Make a folder in Dropbox/iCloud/Whatever and init a local repo. Download the minified Phaser and start coding. No npm, no Babel, no baggage.

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Absolutely got to read your post, I'm writing an article on medium about Phaser CE
I should reverse the step with

  • git init first
  • create the repository right after

The thing is as I said I am starting to use the GitHub app to clone directly the repos I like to participate so I am sure that it will pull the last changes without command line

Collapse
 
helenanders26 profile image
Helen Anderson • Edited

I do exactly what you've described and have written myself some instructions

Learning about branching, merging and, at some point contributing to open source, is all on my list of things to learn about.

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa

I've discovered gitkraken in this thread and it's fine to just follow opensource projects,
I am a cmder user too, I plan to switch to ubuntu shell on Windows 10 as soon as I have a new computer

Collapse
 
alyson profile image
aly quey

Create repo on github/gitlab -> git init on local -> create .gitignore
-> git add .gitignore -> git commit -m 'initial commit' -> add remote origin -> push
-> checkout -b develop -> git push origin HEAD -> branch setting on remote (protect/CI etc)
-> checkout -b feature/xxxxxxx -> push origin HEAD -> Pull Request -> SELF REVIEW
-> squash merge -> rebase origin develop -> ..... continue ( ˙꒳​˙ )

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

woohoo I follow you until git commit -m "Initial commit" then am lost XD

Collapse
 
vip3rousmango profile image
Al Romano

If there are coworkers around or it's a presentation, then everything is via terminal so I can maintain my cool hacker status.

Alone at my own station I use Gitkraken pretty much exclusively even if the IDE has Git integrated (as most do...).

Sure git is pretty straightforward and I love me some terminal only action but I love Gitkraken's UI and how everything is super easy to do, update, read and analyse.

Highly recommended it. :)

Collapse
 
pkristiancz profile image
Patrik Kristian

simillar steps, fake account not used, after initial commit with readme i commit more.. you know.. actualy do something. try it :P

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Indeed I have to commit more but as you said you know ... I think it's the motivation behind to finish something. Anyway, fake accounts are usefull for gamejams and ofc trolls XD
Thx for the feedback ;)

Collapse
 
jackharner profile image
Jack Harner πŸš€

I pretty much only work with myself so I've been using git more as a dedicated back up/move code between different machines tool.

git add . 

git commit -m "a lot of shit"

git push
Collapse
 
moopet profile image
Ben Sinclair

I don't understand what "when I start a project on GitHub, the first thing I do is to create a project on my profile on the site" means - could you explain a bit further?

Collapse
 
nazimboudeffa profile image
Nazim Boudeffa • Edited

Just commented on a Reply that uses git init first then create the repo instead of doing things like me got to think about it because sometimes it just create an empty repo for a while untill the "proof of concept" phase (another comment in this thread)

Thx for the relevant comment :)

Collapse
 
jameslivesey profile image
James Livesey

I use VSCode. I just:

  1. Ctrl + Shift + G
  2. (Type in my commit message)
  3. Ctrl + Enter
  4. Ctrl + Shift + P
  5. "git push", Enter
  6. Ctrl + Shift + E
  7. Ctrl + 1

Rinse and repeat.