DEV Community

Nazim Boudeffa
Nazim Boudeffa

Posted on • Edited on

How do you commit in GitHub ?

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 the site

After that I clone the repo then I code for example a Phaser game to participate in a gamejam on itch.io/jams with one of my fake accounts

Then :

  • git add .
    I use precisely the dot nothing else

  • git commit -m "First Commit"
    I don't know the diffrence with "Initial Commit"

  • git push origin main
    OFC I use git config user.name/user.email before all this to use my fake accounts

I repeat these steps ... and never finish a project

Latest comments (36)

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
 
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.

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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

Some comments may only be visible to logged-in visitors. Sign in to view all comments.